package com.opmsys.mapper;

import com.github.pagehelper.Page;
import com.opmsys.pojo.dto.RepairPageDTO;
import com.opmsys.pojo.entity.Repair;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;

@Mapper
public interface RepairMapper {


    /**
     * 插入一条维修记录
     * @param repair
     */
    @Insert("insert into t_repair" +
            "(repair_date, repair_items, repair_details, accident_id, person_number, pump_id) " +
            "VALUES (#{repairDate},#{repairItems},#{repairDetails},#{accidentId},#{personNumber},#{pumpId})")
    void insert(Repair repair);


    /**
     * 更新维修记录
     * @param repair
     */
    void update(Repair repair);

    /**
     * 删除一条维修记录
     * @param id
     */
    @Delete("delete from t_repair where id = #{id}")
    void deleteById(Integer id);

    /**
     * 维修记录分页查询
     * @param repairPageDTO
     * @return
     */
    Page<Repair> pageQuery(RepairPageDTO repairPageDTO);

    @Delete("delete from t_repair where accident_id = #{id}")
    void deleteByAccidentId(Integer id);
}
